package threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author sesshomaru
 * @date 2021/10/12 19:44
 */
public class ScheduledTheadPool {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(10);
        // 延迟5秒启动
        // scheduledThreadPool.schedule(new Task(), 5, TimeUnit.SECONDS);
        // 延迟1秒启动，然后没个3秒执行一次任务
        scheduledThreadPool.scheduleAtFixedRate(new Task(), 1,3,TimeUnit.SECONDS);
    }
}
